
/*
//模拟实现推特
class Twitter {

    public HashMap<Integer,List<Integer>> follow;
    public List<int[]> list;
    public Twitter() {
        follow = new HashMap<>();
        list = new ArrayList<>();
    }

    public void postTweet(int userId, int tweetId) {
        list.add(new int[]{userId,tweetId});
    }

    public List<Integer> getNewsFeed(int userId) {
        List<Integer> fol = new ArrayList<>();
        fol.add(userId);
        if (follow.containsKey(userId)) {
            fol.addAll(follow.get(userId));
        }
        List<Integer> ans = new ArrayList<>();
        for (int i = list.size() - 1, cnt = 0; i >= 0 && cnt < 10; i--) {
            int[] a = list.get(i);
            if (fol.contains(a[0])) {
                ans.add(a[1]);
                cnt++;
            }
        }
        return ans;
    }

    public void follow(int followerId, int followeeId) {
        if(follow.containsKey(followerId)){
            follow.get(followerId).add(followeeId);
        }else{
            follow.put(followerId,new ArrayList<>(Arrays.asList(followeeId)));
        }
    }

    public void unfollow(int followerId, int followeeId) {
        if(follow.containsKey(followerId)){
            List<Integer> tmp = follow.get(followerId);
            for (int i = 0; i < tmp.size(); i++) {
                if(tmp.get(i) == followeeId){
                    tmp.remove(i);
                }
            }
        }
    }
}
*/
